package net.organizer.ui.actionhandler.message;

import org.json.JSONException;
import org.json.JSONObject;

public class DuplicateFieldMessage {
	private String fieldName;
	private String name = "duplicate_field";

	public JSONObject toJSONObject() {
		JSONObject result = new JSONObject();
		try {
			result.put("fieldName", fieldName);
			result.put("name", this.name);
		} catch (JSONException e) {
			throw new RuntimeException(e);
		}
		return result;
	}

	public DuplicateFieldMessage(String fieldName, JSONObject respJSONObject) {
		super();
		this.fieldName = fieldName;
		try {
			respJSONObject.put("error_message", this.toJSONObject());
		} catch (JSONException e) {
			throw new RuntimeException(e);
		}
	}
}
